<template>
  <div class="page-content page-prj">
    <div class="page-prj__left flex-y">
      <LeftTop class="flex-1" :data="newTimeData"/>
      <LeftCenter class="flex-1" mt-20  :data="newTimeData"/>
      <LeftBottom class="flex-1" mt-20 :data="newTimeData"/>
      <LeftLast class="flex-1" mt-20 :data="peopleTrendTime" @childEvent="handleChildEvent"/>
    </div>
    <div class="page-prj__center flex-y">
      <CenterTop class="flex-2"  :data="MonitoringPointsData"/>
      <CenterBottom class="flex-1" mt-20 :data="newTimeData"/>
    </div>
    <div class="page-prj__right flex-y">
      <RightTop class="flex-1" :data="newTimeData"/>
      <RightCenter class="flex-1" mt-20 :data="PeopleTrendData" @childEvent="peopleHandleChildEvent"/>
      <RightBottom class="flex-1" mt-20 :data="newTimeData"/>
      <RightLast class="flex-1" mt-20 />
    </div>
  </div>
</template>

<script setup>

// left
import LeftTop from "./parts/left-top.vue";
import LeftCenter from "./parts/left-center.vue";
import LeftBottom from "./parts/left-bottom.vue";
import LeftLast from './parts/left-last.vue';

// center
import CenterTop from "./parts/center-top.vue";
import CenterBottom from "./parts/center-bottom.vue";

// right
import RightTop from "./parts/right-top.vue";
import RightCenter from "./parts/right-center.vue";
import RightBottom from "./parts/right-bottom.vue";
import RightLast from './parts/right-last.vue'

import { computed, onMounted, ref, watch,onUnmounted } from "vue";
import { useStore } from "@/store";
import { numberFormat } from "@/utils";

import { colCfg } from "./cfg";
import { format } from "echarts";
import  api from "../../api/people-board"

const newTimeData = ref()
const peopleTrendTime = ref()
const MonitoringPointsData =ref()
const PeopleTrendData =ref()

const leftTime =ref("1")
const rightTime =ref("1")
let timer;
const handleChildEvent =(v)=>{
  clearInterval(timer);
  leftTime.value=String(v+1)
  getAllData()
  timer = setInterval(getAllData, 5000);
}

const peopleHandleChildEvent=(v)=>{
  clearInterval(timer);
  rightTime.value=String(v+1)
  getAllData()
  timer = setInterval(getAllData, 5000);
}

const getAllData =()=>{
  // 人员信息+部门人数+今日访客+出入记录+当日告警数据+当日门禁通行量
  api.getPeopleManyData({}).then((res)=>{
    newTimeData.value = res?.data
    
  })

  // 根据时间获取人员态势趋势图
  api.getPeopleTrendTime({type:leftTime.value}).then(res=>{
    peopleTrendTime.value = res?.data
     
  })

  // 获取人员通行趋势
  api.getPeopleTrend({type:rightTime.value}).then(res=>{
    PeopleTrendData.value=res?.data
  
  })
}

// 获取项目
onMounted(() => { 
  getAllData()
  timer = setInterval(getAllData, 10000);

});

onUnmounted(() => {
    clearInterval(timer);
});



</script>

<style lang="scss" scoped>
.page-prj {
  justify-content: space-between;

  &__left,
  &__right {
    width: 540px;
  }

  &__center {
    margin: 0px 20px;
    position: relative;
    flex: 1;
    width: 0px;
    display: flex;
    flex-direction: column;
  }

  .legend-box {
    position: absolute;
    right: 12px;
    bottom: 12px;
    padding: 13px 15px;
    border: 1px solid #24c1f7;
    z-index: 100;
    background-color: rgba(18, 33, 76, 0.8);
    display: flex;
    flex-direction: column;

    .el-checkbox {
      &:nth-child(n + 2) {
        margin-top: 16px;
      }

      --el-checkbox-disabled-checked-input-fill: #409eff;
      --el-checkbox-disabled-checked-input-border-color: #409eff;
      --el-checkbox-disabled-checked-icon-color: #ffffff;

      ::v-deep(.el-checkbox__label) {
        display: inline-flex;
        align-items: center;
      }

      img {
        width: 28px;
      }

      span {
        margin-left: 10px;
        font-weight: 600;
        font-weight: 500;
        font-size: 16px;
        color: #cfe9ff;
      }
    }
  }
}

.content-box1 {
  ::v-deep {
    .content-box {
      width: 70% !important;
    }
  }
}
</style>

<style lang="scss">
.prj-name {
  flex: 2 !important;
}

.dept-name {
  min-width: 300px !important;
}
</style>
